﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using System.Threading;
using System.Net.Mail;

namespace Arrb.Controllers
{
    public class ContactoController : Controller
    {
        //
        // GET: /Contacto/
        public ActionResult Index()
        {
            return View("Contacto");
        }

        public ActionResult SendFeedback(string message)
        {
            try
            {
                MailMessage mailObj = new MailMessage(
                "valentina.trujillo@gmail.com", "valentina.trujillo@gmail.com", "Feedback", message);
                SmtpClient SMTPServer = new SmtpClient("smtp.gmail.com");
                try
                {
                    SMTPServer.Send(mailObj);
                }
                catch (Exception ex)
                {
                    Console.WriteLine( ex.ToString());
                }
                /*
                BLL.Email mail = new BLL.Email();
                string from = "feedback@arrb.com";
                string to = "valentina.trujillo@gmail.com";
                    //System.Configuration.ConfigurationManager.AppSettings["CorreoFeedback"].ToString();
                List<string> tos = new List<string>();
                tos.Add(to);
                mail.From = from;
                mail.To = tos;
                mail.Subject = "Feedback ARRB Site";
                mail.Cuerpo = message;

                ThreadPool.QueueUserWorkItem(new WaitCallback(BLL.Email.SendAlertaAsync), mail);*/
            }
            catch
            {
                return Json("El correo no pudo ser enviado" );
            }

            return Json("Correo enviado con éxito");
        }
    }
}
